button: Fix ::clicked emission on touchscreens sending pointer events
authorCarlos Garnacho <carlosg@gnome.org>
Thu, 25 Sep 2014 13:24:46 +0000 (15:24 +0200)
committerCarlos Garnacho <carlosg@gnome.org>
Thu, 25 Sep 2014 19:25:52 +0000 (21:25 +0200)
When GtkGestureMultiPress::released happens, in_button should be unset
after emitting GtkButton::released, whose default implementation uses it.
Moreover, in_button should only be unset there for real touch events, not
guaranteed to trigger crossing events, as opposed to every pointer/touch
events from touchscreens.

https://bugzilla.gnome.org/show_bug.cgi?id=737297

gtk/gtkbutton.c

index 4f0fdc193643bbb180d1cf28169d22d3aa8e6000..207bcbcacaf244e4de2672b5e84847e9d5f58f87 100644 (file)
@@ -607,18 +607,16 @@ multipress_released_cb (GtkGestureMultiPress *gesture,
   GtkButton *button = GTK_BUTTON (widget);
   GtkButtonPrivate *priv = button->priv;
   GdkEventSequence *sequence;
-  const GdkEvent *event;
-  GdkDevice *source;
+
+  g_signal_emit (button, button_signals[RELEASED], 0);
 
   sequence = gtk_gesture_single_get_current_sequence (GTK_GESTURE_SINGLE (gesture));
-  event = gtk_gesture_get_last_event (GTK_GESTURE (gesture), sequence);
-  if (event)
+
+  if (sequence)
     {
-      source = gdk_event_get_source_device (event);
-      if (source && gdk_device_get_source (source) == GDK_SOURCE_TOUCHSCREEN)
-        priv->in_button = FALSE;
+      priv->in_button = FALSE;
+      gtk_button_update_state (button);
     }
-  g_signal_emit (button, button_signals[RELEASED], 0);
 }
 
 static void